<template>
  <div id="cart">
    <!-- 导航 -->
     <nav-bar class="nav-bar">
      <div slot="center">购物车({{length}})</div>
    </nav-bar>
     <cart-list class="cart-list" :cart-list="cartList"></cart-list>

    <!-- 商品的列表 -->
    <cart-list></cart-list>
    <!-- 底部的汇总 -->
    <cart-bottom-bar></cart-bottom-bar>
  </div>
</template>

<script>
import NavBar from '@/components/common/navbar/NavBar';
import CartList from './childComps/CartList';
import CartBottomBar from './childComps/CartBottomBar';

import { mapGetters } from 'vuex';


export default {
  name: 'Cart',
  data() { 
    return {

    }
  },
  components:{
    NavBar,
    CartList,
    CartBottomBar
  },
  computed:{
    //mapGetters的第一种用法
    // ...mapGetters(['cartLength','cartList']),
    //第二种用法
    ...mapGetters({
      length: 'cartLength',
      list: 'cartList'
    }),
    /* cartLength(){
      return this.$store.getters.cartLength
    } */
    cartList() {
		    return this.$store.getters.cartList
      },
     /*  cartCount() {
		    return this.$store.getters.cartCount
      } */
  }
 }
</script>

<style  scoped>
  #cart {
    /*position: relative;*/
    height: 100vh;
  }

  .nav-bar {
    background-color: var(--color-tint);
    /* font-weight: 700; */
    color: #fff;
    font-size: 16px;
  }

  .cart-list {
    position: absolute;
    top: 44px;
    bottom: 49px;
    width: 100%;
  }
</style>